package com.csht.controller;

import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csht.model.City;
import com.csht.model.CshtAdvice;
import com.csht.model.CshtLunbo;
import com.csht.model.CshtUser;
import com.csht.model.Province;
import com.csht.model.School;
import com.csht.service.CshtAdviceService;
import com.csht.service.IndexService;
import com.csht.vo.index.IndexDataVo;
import com.csht.vo.index.menu.CshtOneMenuVo;
import com.csht.vo.index.shangpinzhangqu.CshtGoodsVo_2;
import com.csht.vo.index.shangpinzhangqu.CshtTwoMenuVo_2;
import com.csht.vo.index.shangpinzhangqu.ShangPinZhangQu;
import com.csht.vo.index.tenGoods.CshtGoodsVo;
import com.csht.vo.index.tenGoods.CshtTenGoodsEverydayVo;
import com.csht.vo.index.user.CshtUserVo;

/**
 * 首页
 * @author chenhuiyan
 *
 */
@Controller
public class IndexController {
	
	@Autowired
	private IndexService indexService;
	
	@Autowired
	private CshtAdviceService cshtAdviceService;
	
	/**
	 * 获取省名称链接
	 */
	private String provinceUrl = "http://119.29.166.254:9090/api/provinces";
	
	/**
	 * 通过省id查找城市
	 */
	private String cityUrl = "http://119.29.166.254:9090/api/province/getCitiesByProvinceId";
	
	/**
	 * 通过城市名获取学校
	 */
	private String schoolUrl = "http://119.29.166.254:9090/api/university/getUniversityByCityName";
	
	/**
	 * 首页
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/index")
	public String index(ModelMap model, HttpServletRequest request, HttpServletResponse response) 
			throws Exception{
		
		//获取登录的用户
		CshtUser cshtUser = (CshtUser) request.getSession().getAttribute("loginUser");
		
		//获取省份
		List<Province> provinceList = indexService.getAllProvince(provinceUrl);
		
		//获取城市
		List<City> cityList = null;
		
		//获取学校
		List<School> schoolList = null;
		
		//获取全部菜单封装类
		List<CshtOneMenuVo> cshtOneMenuVoList = indexService.getAllMenu();
		
		//获取轮播
		List<CshtLunbo> cshtLunboList = indexService.getLunbo();
		
		//获取每日十件商品
		List<CshtTenGoodsEverydayVo> cshtTenGoodsEverydayVoList = null;
		
		//获取商品展区封装类
		List<ShangPinZhangQu> shangPinZhangQu = null;
		
		//用户拓展类
		CshtUserVo cshtUserVo = null;
		
		//有用户登录时
		if(cshtUser != null) {
			System.out.println("用户登录    地址：" + cshtUser.getUserAddress());
			//地址存入cookie
			Cookie ckprovinceId = null;
			for(Province province :provinceList) {
				if(province.getName().equals(cshtUser.getUserAddress().split("-")[0])) {
					ckprovinceId = new Cookie("provinceId", province.getId().toString());
				}
			}
			Cookie ckprovinceName = new Cookie("provinceName", URLEncoder.encode(cshtUser.getUserAddress().split("-")[0], "utf-8"));
			Cookie ckcityName = new Cookie("cityName", URLEncoder.encode(cshtUser.getUserAddress().split("-")[1], "utf-8"));
			Cookie ckschoolName = new Cookie("schoolName", URLEncoder.encode(cshtUser.getUserAddress().split("-")[2], "utf-8"));
			response.addCookie(ckprovinceId);
			response.addCookie(ckprovinceName);
			response.addCookie(ckcityName);
			response.addCookie(ckschoolName);
			
			//根据用户地址获取每日十件商品，进行封装处理
			List<CshtGoodsVo> cshtGoodsVoList = indexService.getTenGoodsToLoginUser(cshtUser.getUserAddress());
			cshtTenGoodsEverydayVoList = new ArrayList<CshtTenGoodsEverydayVo>();
			for(int i = 0; i < cshtGoodsVoList.size(); i++) {
				CshtTenGoodsEverydayVo cshtTenGoodsEverydayVo = new CshtTenGoodsEverydayVo();
				cshtTenGoodsEverydayVo.setCshtGoodsVo(cshtGoodsVoList.get(i));
				cshtTenGoodsEverydayVoList.add(i, cshtTenGoodsEverydayVo);
			}
			
			//获取商品展区封装类，进行封装处理
			List<ShangPinZhangQu> shangPinZhangQuList = indexService.getOneMenuAndBanner();//获取一级菜单
			List<CshtTwoMenuVo_2> cshtTwoMenuVo_2List = indexService.getTTMG(cshtUser.getUserId());
			for(int i = 0; i < shangPinZhangQuList.size(); i++) {
				List<CshtTwoMenuVo_2> cshtTwoMenuVo_2List_1 = new ArrayList<CshtTwoMenuVo_2>();
				for(int j = 0; j < cshtTwoMenuVo_2List.size(); j++) {
					if(shangPinZhangQuList.get(i).getOneMenuId() == cshtTwoMenuVo_2List.get(j).getOneMenuId()) {
						cshtTwoMenuVo_2List_1.add(cshtTwoMenuVo_2List.get(j));
					}
				}
				
				shangPinZhangQuList.get(i).setCshtTwoMenuVo_2List(cshtTwoMenuVo_2List_1);
			}
			shangPinZhangQu = shangPinZhangQuList;
			
			//获取城市
			Integer provinceId = 0;
			for(Province province : provinceList) {
				if(province.getName().equals(cshtUser.getUserAddress().split("-")[0])) {
					provinceId = province.getId();
				}
			}
			cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
			
			//获取学校
			schoolList = indexService.getAllSchoolByCityName(schoolUrl, cshtUser.getUserAddress().split("-")[1]);
			
			//封装用户拓展类
			cshtUserVo = this.getCshtUserVo(cshtUser, request);
			cshtUserVo.setCity(cshtUser.getUserAddress().split("-")[1]);
			cshtUserVo.setProvince(cshtUser.getUserAddress().split("-")[0]);
			cshtUserVo.setSchool(cshtUser.getUserAddress().split("-")[2]);
			
			
		}else {//没有登录
			System.out.println("没有登录 ");
			//获取每日十件商品
			cshtTenGoodsEverydayVoList = indexService.getTenGoods();
			//获取商品展区封装类
			shangPinZhangQu = indexService.getShangPinZhangQu();
		}
		
		
		//封装全部数据
		IndexDataVo indexDateVo = new IndexDataVo();
		indexDateVo.setProvinceList(provinceList);
		indexDateVo.setCshtOneMenuVoList(cshtOneMenuVoList);
		indexDateVo.setCshtLunboList(cshtLunboList);
		indexDateVo.setCshtTenGoodsEverydayVoList(cshtTenGoodsEverydayVoList);
		indexDateVo.setShangPinZhangQu(shangPinZhangQu);
		indexDateVo.setCityList(cityList);
		indexDateVo.setSchoolList(schoolList);
		indexDateVo.setCshtUserVo(cshtUserVo);
		model.addAttribute("indexDateVo", indexDateVo);
		request.getSession().setAttribute("cshtUserVo", cshtUserVo);
		request.getSession().setAttribute("cityList", cityList);
		request.getSession().setAttribute("schoolList", schoolList);
		request.getSession().setAttribute("provinceList", provinceList);
		request.getSession().setAttribute("cshtOneMenuVoList", cshtOneMenuVoList);
		
		return "/index";
	}
	
	/**
	 * 添加建议反馈
	 * @param cshtAdvice
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping(value = "/insertAdvice")
	public Map<String, Object> insertAdvice(CshtAdvice cshtAdvice, HttpServletRequest request) 
			throws Exception{
		Map<String, Object> messages = new HashMap<String, Object>();
		messages.put("message", false);
		CshtUser cshtUser = (CshtUser) request.getSession().getAttribute("loginUser");
		cshtAdvice.setAdviceReadState("未读");
		cshtAdvice.setAdviceReadTime(new Date());
		cshtAdvice.setUserId(cshtUser.getUserId());
		cshtAdviceService.insertAdvice(cshtAdvice);
		messages.put("message", true);
		return messages;
	}
	
	/**
	 * 定位省改变
	 * @param provinceId
	 * @param ProvinceName
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/positionToProvince")
	public String positionToProvince(@RequestParam(name = "provinceId") Integer provinceId, 
			@RequestParam(name = "provinceName") String provinceName, HttpServletResponse response, 
			HttpServletRequest request, ModelMap model) throws Exception{
		System.out.println("省id:" + provinceId);
		//保存省id和省名称到cookie，默认关闭浏览器就清掉
		Cookie ckprovinceId = new Cookie("provinceId", provinceId.toString());
		Cookie ckprovinceName = new Cookie("provinceName", URLEncoder.encode(provinceName, "utf-8"));
		response.addCookie(ckprovinceId);
		response.addCookie(ckprovinceName);
		//初始化城市和学校cookie
		Cookie cityName = new Cookie("cityName", URLEncoder.encode("", "utf-8"));
		Cookie schoolName = new Cookie("schoolName", URLEncoder.encode("", "utf-8"));
		response.addCookie(cityName);
		response.addCookie(schoolName);
		
		//获取登录的用户
		CshtUser cshtUser = (CshtUser) request.getSession().getAttribute("loginUser");
		
		//获取省份
		List<Province> provinceList = indexService.getAllProvince(provinceUrl);
		
		//获取城市
		List<City> cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
		
		//获取全部菜单封装类
		List<CshtOneMenuVo> cshtOneMenuVoList = indexService.getAllMenu();
		
		//获取轮播
		List<CshtLunbo> cshtLunboList = indexService.getLunbo();
		
		//获取每日十件商品
		List<CshtTenGoodsEverydayVo> cshtTenGoodsEverydayVoList = null;
		
		//获取商品展区封装类
		List<ShangPinZhangQu> shangPinZhangQu = null;
		
		//用户拓展类
		CshtUserVo cshtUserVo = null;
		
		//根据省定位改变获取每日十件商品，进行封装处理
		String address = provinceId == 0? "-" : provinceName;
		List<CshtGoodsVo> cshtGoodsVoList = indexService.getGoodsByAddress(address);
		cshtTenGoodsEverydayVoList = new ArrayList<CshtTenGoodsEverydayVo>();
		for(int i = 0; i < cshtGoodsVoList.size(); i++) {
			CshtTenGoodsEverydayVo cshtTenGoodsEverydayVo = new CshtTenGoodsEverydayVo();
			cshtTenGoodsEverydayVo.setCshtGoodsVo(cshtGoodsVoList.get(i));
			cshtTenGoodsEverydayVoList.add(i, cshtTenGoodsEverydayVo);
		}
		
		//（商品展区）根据省定位改变和二级菜单id获取商品
		List<ShangPinZhangQu> shangPinZhangQuList = indexService.getOneMenu();//获取一级菜单
		Map<String, String> tIdAndPName = new HashMap<String, String>();
		for(int i = 0; i < shangPinZhangQuList.size(); i++) {
			for(int j = 0; j < shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().size(); j++) {
				tIdAndPName.put("twoMenuId", shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).getTwoMenuId().toString());
				tIdAndPName.put("position", address);
				//根据二级菜单id和定位值查找商品
				List<CshtGoodsVo_2> cshtGoodsVo_2List = indexService.getGoodsByTwoMenuIdAndposition(tIdAndPName);
				//查找到的商品封装到shangPinZhangQuList
				shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).setCshtGoodsVo_2List(cshtGoodsVo_2List);
			}
		}
		shangPinZhangQu = shangPinZhangQuList;
		if(cshtUser != null) {
			//封装用户拓展类
			cshtUserVo = this.getCshtUserVo(cshtUser, request);
			cshtUserVo.setCity("");
			cshtUserVo.setProvince(provinceName);
			cshtUserVo.setSchool("");
		}
		//封装全部数据
		IndexDataVo indexDateVo = new IndexDataVo();
		indexDateVo.setProvinceList(provinceList);
		indexDateVo.setCshtOneMenuVoList(cshtOneMenuVoList);
		indexDateVo.setCshtLunboList(cshtLunboList);
		indexDateVo.setCshtTenGoodsEverydayVoList(cshtTenGoodsEverydayVoList);
		indexDateVo.setShangPinZhangQu(shangPinZhangQu);
		indexDateVo.setCityList(cityList);
		indexDateVo.setCshtUserVo(cshtUserVo);
		model.addAttribute("indexDateVo", indexDateVo);
		request.getSession().setAttribute("provinceName", provinceName);
		request.getSession().setAttribute("cshtUserVo", cshtUserVo);
		request.getSession().setAttribute("cityList", cityList);
		request.getSession().setAttribute("schoolList", null);
		request.getSession().setAttribute("provinceList", provinceList);
		return "/index";
	}
	
	/**
	 * 定位城市改变
	 * @param provinceId
	 * @param ProvinceName
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/positionToCity")
	public String positionToCity(@RequestParam(name = "cityName") String cityName, 
			HttpServletResponse response, HttpServletRequest request, ModelMap model) 
					throws Exception{
		System.out.println("城市名称：" + cityName);
		//保存城市名称到cookie，默认关闭浏览器就清掉
		Cookie ckcityName = new Cookie("cityName", URLEncoder.encode(cityName, "utf-8"));
		response.addCookie(ckcityName);
		//初始化学校cookie
		Cookie schoolName = new Cookie("schoolName", URLEncoder.encode("", "utf-8"));
		response.addCookie(schoolName);
		
		//从cookie获取省id和名称
		Cookie[] ck = request.getCookies();
		Integer provinceId = 0;
		String provinceName = "";
		for(Cookie c : ck) {
			if("provinceId".equals(c.getName())) {
				provinceId = Integer.parseInt(c.getValue());
			}
			if("provinceName".equals(c.getName())) {
				provinceName = URLDecoder.decode(c.getValue(), "utf-8");
			}
		}
		System.out.println(provinceName + "   " + provinceId + "   " + cityName);
		//获取登录的用户
		CshtUser cshtUser = (CshtUser) request.getSession().getAttribute("loginUser");
		
		//获取省份
		List<Province> provinceList = indexService.getAllProvince(provinceUrl);
		
		//获取城市
		List<City> cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
		
		//获取学校
		List<School> schoolList = indexService.getAllSchoolByCityName(schoolUrl, cityName);
		
		//获取全部菜单封装类
		List<CshtOneMenuVo> cshtOneMenuVoList = indexService.getAllMenu();
		
		//获取轮播
		List<CshtLunbo> cshtLunboList = indexService.getLunbo();
		
		//获取每日十件商品
		List<CshtTenGoodsEverydayVo> cshtTenGoodsEverydayVoList = null;
		
		//获取商品展区封装类
		List<ShangPinZhangQu> shangPinZhangQu = null;
		
		//用户拓展类
		CshtUserVo cshtUserVo = null;
		
		//根据省定位改变获取每日十件商品，进行封装处理
		String address = cityName.equals("全部城市")? provinceName : provinceName + "-" + cityName;
		List<CshtGoodsVo> cshtGoodsVoList = indexService.getGoodsByAddress(address);
		cshtTenGoodsEverydayVoList = new ArrayList<CshtTenGoodsEverydayVo>();
		for(int i = 0; i < cshtGoodsVoList.size(); i++) {
			CshtTenGoodsEverydayVo cshtTenGoodsEverydayVo = new CshtTenGoodsEverydayVo();
			cshtTenGoodsEverydayVo.setCshtGoodsVo(cshtGoodsVoList.get(i));
			cshtTenGoodsEverydayVoList.add(i, cshtTenGoodsEverydayVo);
		}
		
		//（商品展区）根据省定位改变和二级菜单id获取商品
		List<ShangPinZhangQu> shangPinZhangQuList = indexService.getOneMenu();//获取一级菜单
		Map<String, String> tIdAndPName = new HashMap<String, String>();
		for(int i = 0; i < shangPinZhangQuList.size(); i++) {
			for(int j = 0; j < shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().size(); j++) {
				tIdAndPName.put("twoMenuId", shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).getTwoMenuId().toString());
				tIdAndPName.put("position", address);
				//根据二级菜单id和定位值查找商品
				List<CshtGoodsVo_2> cshtGoodsVo_2List = indexService.getGoodsByTwoMenuIdAndposition(tIdAndPName);
				//查找到的商品封装到shangPinZhangQuList
				shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).setCshtGoodsVo_2List(cshtGoodsVo_2List);
			}
		}
		shangPinZhangQu = shangPinZhangQuList;
		if(cshtUser != null) {
			//封装用户拓展类
			cshtUserVo = this.getCshtUserVo(cshtUser, request);
			cshtUserVo.setCity(cityName);
			cshtUserVo.setProvince(provinceName);
			cshtUserVo.setSchool("");
		}
		//封装全部数据
		IndexDataVo indexDateVo = new IndexDataVo();
		indexDateVo.setProvinceList(provinceList);
		indexDateVo.setCshtOneMenuVoList(cshtOneMenuVoList);
		indexDateVo.setCshtLunboList(cshtLunboList);
		indexDateVo.setCshtTenGoodsEverydayVoList(cshtTenGoodsEverydayVoList);
		indexDateVo.setShangPinZhangQu(shangPinZhangQu);
		indexDateVo.setCityList(cityList);
		indexDateVo.setSchoolList(schoolList);
		indexDateVo.setCshtUserVo(cshtUserVo);
		model.addAttribute("indexDateVo", indexDateVo);
		request.getSession().setAttribute("provinceName", provinceName);
		request.getSession().setAttribute("cityName", cityName);
		request.getSession().setAttribute("cshtUserVo", cshtUserVo);
		request.getSession().setAttribute("cityList", cityList);
		request.getSession().setAttribute("schoolList", schoolList);
		request.getSession().setAttribute("provinceList", provinceList);
		return "/index";
	}
	
	/**
	 * 定位学校改变
	 * @param provinceId
	 * @param ProvinceName
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/positionToSchool")
	public String positionToSchool(@RequestParam(name = "schoolName") String schoolName, 
			HttpServletResponse response, HttpServletRequest request, ModelMap model) 
					throws Exception{
		System.out.println("学校名称：" + schoolName);
		//保存城市名称到cookie，默认关闭浏览器就清掉
		Cookie ckschoolName = new Cookie("schoolName", URLEncoder.encode(schoolName, "utf-8"));
		response.addCookie(ckschoolName);
		
		//从cookie获取省id、省名称、城市名称
		Cookie[] ck = request.getCookies();
		Integer provinceId = 0;
		String provinceName = "";
		String cityName = "";
		for(Cookie c : ck) {
			if("provinceId".equals(c.getName())) {
				provinceId = Integer.parseInt(c.getValue());
			}
			if("provinceName".equals(c.getName())) {
				provinceName = URLDecoder.decode(c.getValue(), "utf-8");
			}
			if("cityName".equals(c.getName())) {
				cityName = URLDecoder.decode(c.getValue(), "utf-8");
			}
		}
		System.out.println(provinceId + "   " + provinceName + "   " + cityName + "   " + schoolName);
		
		//获取登录的用户
		CshtUser cshtUser = (CshtUser) request.getSession().getAttribute("loginUser");
		
		//获取省份
		List<Province> provinceList = indexService.getAllProvince(provinceUrl);
		
		//获取城市
		List<City> cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
		
		//获取学校
		List<School> schoolList = indexService.getAllSchoolByCityName(schoolUrl, cityName);
		
		//获取全部菜单封装类
		List<CshtOneMenuVo> cshtOneMenuVoList = indexService.getAllMenu();
		
		//获取轮播
		List<CshtLunbo> cshtLunboList = indexService.getLunbo();
		
		//获取每日十件商品
		List<CshtTenGoodsEverydayVo> cshtTenGoodsEverydayVoList = null;
		
		//获取商品展区封装类
		List<ShangPinZhangQu> shangPinZhangQu = null;
		
		//用户拓展类
		CshtUserVo cshtUserVo = null;
		
		//根据省定位改变获取每日十件商品，进行封装处理
		String address = schoolName.equals("全部学校")? provinceName + "-" + cityName : provinceName + "-" + cityName + "-" + schoolName;
		List<CshtGoodsVo> cshtGoodsVoList = indexService.getGoodsByAddress(address);
		cshtTenGoodsEverydayVoList = new ArrayList<CshtTenGoodsEverydayVo>();
		for(int i = 0; i < cshtGoodsVoList.size(); i++) {
			CshtTenGoodsEverydayVo cshtTenGoodsEverydayVo = new CshtTenGoodsEverydayVo();
			cshtTenGoodsEverydayVo.setCshtGoodsVo(cshtGoodsVoList.get(i));
			cshtTenGoodsEverydayVoList.add(i, cshtTenGoodsEverydayVo);
		}
		
		//（商品展区）根据省定位改变和二级菜单id获取商品
		List<ShangPinZhangQu> shangPinZhangQuList = indexService.getOneMenu();//获取一级菜单
		Map<String, String> tIdAndPName = new HashMap<String, String>();
		for(int i = 0; i < shangPinZhangQuList.size(); i++) {
			for(int j = 0; j < shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().size(); j++) {
				tIdAndPName.put("twoMenuId", shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).getTwoMenuId().toString());
				tIdAndPName.put("position", address);
				//根据二级菜单id和定位值查找商品
				List<CshtGoodsVo_2> cshtGoodsVo_2List = indexService.getGoodsByTwoMenuIdAndposition(tIdAndPName);
				//查找到的商品封装到shangPinZhangQuList
				shangPinZhangQuList.get(i).getCshtTwoMenuVo_2List().get(j).setCshtGoodsVo_2List(cshtGoodsVo_2List);
			}
		}
		shangPinZhangQu = shangPinZhangQuList;
		if(cshtUser != null) {
			//封装用户拓展类
			cshtUserVo = this.getCshtUserVo(cshtUser, request);
			cshtUserVo.setCity(cityName);
			cshtUserVo.setProvince(provinceName);
			cshtUserVo.setSchool(schoolName);
		}
		//封装全部数据
		IndexDataVo indexDateVo = new IndexDataVo();
		indexDateVo.setProvinceList(provinceList);
		indexDateVo.setCshtOneMenuVoList(cshtOneMenuVoList);
		indexDateVo.setCshtLunboList(cshtLunboList);
		indexDateVo.setCshtTenGoodsEverydayVoList(cshtTenGoodsEverydayVoList);
		indexDateVo.setShangPinZhangQu(shangPinZhangQu);
		indexDateVo.setCityList(cityList);
		indexDateVo.setSchoolList(schoolList);
		indexDateVo.setCshtUserVo(cshtUserVo);
		model.addAttribute("indexDateVo", indexDateVo);
		request.getSession().setAttribute("provinceName", provinceName);
		request.getSession().setAttribute("cityName", cityName);
		request.getSession().setAttribute("schoolName", schoolName);
		request.getSession().setAttribute("cshtUserVo", cshtUserVo);
		request.getSession().setAttribute("cityList", cityList);
		request.getSession().setAttribute("schoolList", schoolList);
		request.getSession().setAttribute("provinceList", provinceList);
		return "/index";
	}
	
	/**
	 * 封装CshtUserVo扩展类重复代码复用
	 * @param cshtUser
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public CshtUserVo getCshtUserVo(CshtUser cshtUser, HttpServletRequest request) throws Exception {
		CshtUserVo cshtUserVo = new CshtUserVo();
		cshtUserVo.setUserAddress(cshtUser.getUserAddress());
		cshtUserVo.setUserGender(cshtUser.getUserGender());
		cshtUserVo.setUserGoodsNumber(indexService.getGoodsNumberByLoginUser(cshtUser.getUserId()));
		cshtUserVo.setUserHeadPath(cshtUser.getUserHeadPath());
		cshtUserVo.setUserId(cshtUser.getUserId());
		cshtUserVo.setUserLockTime(cshtUser.getUserLockTime());
		cshtUserVo.setUserLoginFailTime(cshtUser.getUserLoginFailTime());
		cshtUserVo.setUserNoticeNumber(indexService.getNoticeNumberByUserId(cshtUser.getUserId()));
		cshtUserVo.setUserPassword(cshtUser.getUserPassword());
		cshtUserVo.setuserqq(cshtUser.getuserqq());
		cshtUserVo.setUserShelvesNumber(indexService.getShelvesNumberByUserId(cshtUser.getUserId()));
		cshtUserVo.setUserStopSeal(cshtUser.getUserStopSeal());
		cshtUserVo.setUserTel(cshtUser.getUserTel());
		cshtUserVo.setUserTradingNumber(indexService.getTradingGoodsNumberByUserId(cshtUser.getUserId()));
		cshtUserVo.setUserUsername(cshtUser.getUserUsername());
		cshtUserVo.setUserViolationsTime(cshtUser.getUserViolationsTime());
		cshtUserVo.setUserWechat(cshtUser.getUserWechat());
		cshtUserVo.setUserTradingSuccessNumber(indexService.getTradingSuccessNumberByUserId(cshtUser.getUserId()));
		
		return cshtUserVo;
	}

	
}
